package com.nucarf.bi.digtalize.bean;

import lombok.Data;

import java.math.BigDecimal;

@Data
public class GlobalRecharge {
    private Long recharge_companyId;
    private Long customer_number;
    private String company_name;
    private Integer is_first;
    private Integer fuel_type_id;
    private String fuel_type_name;
    private Long recharge_agreement_id;
    private String recharge_agreement_name;
    private Long sign_agreement_id;
    private String sign_agreement_name;
    private String credit_code;
    private Integer type;
    private BigDecimal money;
    private Integer account_type;
    private Long account_id;
    private String account_name;
    private Long son_account_id;
    private String son_account_name;
    private Long create_time;

    public SinkKafkaBean copyToSinkKafkaBean(String rechargeTopic, String defaultCusCode) {
        SinkKafkaBean sinkBean = new SinkKafkaBean<PushRecharge>();
        String cusCode;
        String companyName;
        Long customer_number = this.customer_number;
        if (customer_number == null || customer_number.intValue() == 0) {
            cusCode = defaultCusCode;
            companyName = "第三方";
        } else {
            cusCode = customer_number.toString();
            companyName = this.company_name;
        }
        sinkBean.setTopic(rechargeTopic);
        sinkBean.setCus_code(cusCode);
        sinkBean.setSource(1);
        sinkBean.setTrade_time(this.create_time);
        PushRecharge pushRecharge = new PushRecharge();
        pushRecharge.setCus_code(cusCode);
        pushRecharge.setTr_type(this.type);
        pushRecharge.setTrade_no(this.recharge_companyId);
        pushRecharge.setIs_first(this.is_first);
        pushRecharge.setSource(1);
        pushRecharge.setCompany_name(companyName);
        if (this.fuel_type_id <= 0 ) {
            pushRecharge.setFuel_code(-1);
            pushRecharge.setFuel_name("混合");
        } else {
            pushRecharge.setFuel_code(this.fuel_type_id);
            pushRecharge.setFuel_name(this.fuel_type_name);
        }
        pushRecharge.setAmount(this.money.divide(new BigDecimal(100)).setScale(4, BigDecimal.ROUND_HALF_UP));
        pushRecharge.setTrade_time(this.create_time);
        pushRecharge.setRemark("");
        sinkBean.setSendBean(pushRecharge);
        return sinkBean;
    }

}
